//
//  AppDelegate.m
//  TaurusXi
//
//  Created by xicheng on 15/11/26.
//  Copyright © 2015年 xicheng. All rights reserved.
//

#import "AppDelegate.h"
#import "MyViewController.h"
#import "MainViewController.h"
#import "HomeViewController.h"
#import "UINavigationController+FDFullscreenPopGesture.h"
#import "Api.h"
#import <CommonCrypto/CommonDigest.h>
#import "NSObject+JRSwizzle.h"
#import "NSDictionary+Unicode.h"

@interface AppDelegate ()

@property(nonatomic,strong)UITabBarController *tabBarVC;
@property(nonatomic,strong)UINavigationController *uINavigationController;

@property(nonatomic,assign)NSTimeInterval timeInterval;
@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  // Override point for customization after application launch
  
  self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  self.window.backgroundColor = [UIColor whiteColor];
  HomeViewController *homeVC = [HomeViewController sharedHomeViewController];
  UINavigationController *nc = [[UINavigationController alloc]initWithRootViewController:homeVC];
  self.window.rootViewController = nc;
  self.uINavigationController = nc;
  [self.window makeKeyAndVisible];
  
  return YES;
}


-(void)pushVC:(UIViewController *)vc{

  [self.uINavigationController pushViewController:vc animated:YES];
}

-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{

  NSString *urlString = [url absoluteString];
  
  if ([urlString hasPrefix:@"taurusmobile"]) {
    return YES;
  }
  return YES;
}

-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
  
  NSString *urlString = [url absoluteString];
  
  if ([urlString hasPrefix:@"taurusmobile"]) {
    
    NSDate* date = [NSDate dateWithTimeIntervalSinceNow:0];
    NSTimeInterval nowDate =[date timeIntervalSince1970]*1000;
    if (nowDate - self.timeInterval > 1.5) {
      [[HomeViewController sharedHomeViewController] openURL:url];
      self.timeInterval = nowDate;
    }
    
    return YES;
  }
  
  return NO;

}


@end
